package com.yix.clould.demo.gateway.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

@Component
@RefreshScope
public class RouteProperties {
    @Value("${spring.cloud.nacos.discovery.server-addr}")
    public String serverAddr;

    @Value("${spring.cloud.nacos.discovery.namespace}")
    public String namespace;

    @Value("${nacos.gateway.route.config.data-id:#{null}}")
    public String dataId;

    @Value("${nacos.gateway.route.config.group:DEFAULT_GROUP:#{null}}")
    public String routeGroup;

    /**
     * 路由配置文件数据获取方式yml,nacos,database
     */
    @Value("${nacos.gateway.route.config.data-type}")
    public String dataType;

    public void setServerAddr(String serverAddr) {
        this.serverAddr = serverAddr;
    }

    public void setNamespace(String namespace) {
        namespace = namespace;
    }

    public void setDataId(String dataId) {
        this.dataId = dataId;
    }

    public void setRouteGroup(String routeGroup) {
        this.routeGroup = routeGroup;
    }

    public void setDataType(String dataType) {
        this.dataType = dataType;
    }

    public String getServerAddr() {
        return serverAddr;
    }

    public String getNamespace() {
        return namespace;
    }

    public String getDataId() {
        return dataId + ".json";
    }

    public String getRouteGroup() {
        return routeGroup;
    }

    public String getDataType() {
        return dataType;
    }
}
